#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n;
  cin >> n;
  vector<char> op(n);
  vector<int> val(n);
  for (int i = 0; i < n; i ++) cin >> op[i] >> val[i];
  op.insert(op.end(), op.begin(), op.end());
  val.insert(val.end(), val.begin(), val.end());
  vector<vector<array<int, 2>>> dp(2 * n, vector<array<int, 2>>(2 * n));
  auto calc = [&](int a, int b, char op) {
    if (op == 't') return a + b;
    return a * b;
  };
  for (int l = 2 * n - 1; l >= 0; l --) {
    dp[l][l] = {val[l], val[l]};
    for (int r = l + 1; r < 2 * n; r ++) {
      dp[l][r] = {INT_MIN, INT_MAX};
      for (int k = l; k < r; k ++) {
        for (int d = 0; d < 4; d ++) {
          dp[l][r][0] = max(dp[l][r][0], calc(dp[l][k][d & 1], dp[k + 1][r][d >> 1 & 1], op[k + 1]));
          dp[l][r][1] = min(dp[l][r][1], calc(dp[l][k][d & 1], dp[k + 1][r][d >> 1 & 1], op[k + 1]));
        }
      }
    }
  }
  int ans = INT_MIN;
  for (int i = 0; i < n; i ++) {
    ans = max(ans, dp[i][i + n - 1][0]);
  }
  cout << ans << endl;
  for (int i = 0; i < n; i ++) {
    if (dp[i][i + n - 1][0] == ans) {
      cout << i + 1 << ' ';
    }
  }
  cout << endl;
}